﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DataCoreTechnologies.Scribe
{
   internal partial class FiltersForm : Form
   {
      //Properties
		internal Business.FilterPreferences FilterPreferences
       {
           get
           {
               return _currentFilterPreferences;
           }
       }
      //Constructor
      internal FiltersForm(Business.FilterPreferences filterPreferences)
      {
         InitializeComponent();
         _initialFilterPreferences = filterPreferences;
         _currentFilterPreferences = Business.FilterPreferences.CreateFilterPreferences();
         _initialFilterPreferences.Copy(_currentFilterPreferences);

			chkTables.Checked = _currentFilterPreferences.GetShowTablesPage;
			chkViews.Checked = _currentFilterPreferences.GetShowViewsPage;
			chkStoredProcedures.Checked = _currentFilterPreferences.GetShowStoredProceduresPage;
			chkFunctions.Checked = _currentFilterPreferences.GetShowFunctionsPage;
			chkIndexes.Checked = _currentFilterPreferences.GetShowIndexesPage;
			chkDataTypes.Checked = _currentFilterPreferences.GetShowDataTypesPage;
			chkSchemas.Checked = _currentFilterPreferences.GetShowSchemasPage;
			chkColumns.Checked = _currentFilterPreferences.GetShowColumnsPage;
			chkDefaultValues.Checked = _currentFilterPreferences.GetShowDefaultValuesPage;
			chkParameters.Checked = _currentFilterPreferences.GetShowParametersPage;
			chkTriggers.Checked = _currentFilterPreferences.GetShowTriggersPage;
      }
      //Form events
		private void btnCancel_Click(object sender, EventArgs e)
		{
			//_currentFilterPreferences.Copy(_initialFilterPreferences);
			DialogResult = DialogResult.Cancel;
			this.Close();
		}
		private void btnSave_Click(object sender, EventArgs e)
		{
         Business.FilterPreferences.SaveFilterPreferences(_currentFilterPreferences);
         DialogResult = DialogResult.OK;
			this.Close();
		}
		//Methods

      //Variables
      private Business.FilterPreferences _initialFilterPreferences;
      private Business.FilterPreferences _currentFilterPreferences;

		private void chkTables_CheckedChanged(object sender, EventArgs e)
		{
			_currentFilterPreferences.SetShowTablesPage = chkTables.Checked;
		}
		private void chkViews_CheckedChanged(object sender, EventArgs e)
		{
			_currentFilterPreferences.SetShowViewsPage = chkViews.Checked;
		}
		private void chkStoredProcedures_CheckedChanged(object sender, EventArgs e)
		{
			_currentFilterPreferences.SetShowStoredProceduresPage = chkStoredProcedures.Checked;
		}
		private void chkFunctions_CheckedChanged(object sender, EventArgs e)
		{
			_currentFilterPreferences.SetShowFunctionsPage = chkFunctions.Checked;
		}
		private void chkIndexes_CheckedChanged(object sender, EventArgs e)
		{
			_currentFilterPreferences.SetShowIndexesPage = chkIndexes.Checked;
		}
		private void chkDataTypes_CheckedChanged(object sender, EventArgs e)
		{
			_currentFilterPreferences.SetShowDataTypesPage = chkDataTypes.Checked;
		}
		private void chkSchemas_CheckedChanged(object sender, EventArgs e)
		{
			_currentFilterPreferences.SetShowSchemasPage = chkSchemas.Checked;
		}
		private void chkColumns_CheckedChanged(object sender, EventArgs e)
		{
			_currentFilterPreferences.SetShowColumnsPage = chkColumns.Checked;
		}
		private void chkDefaultValues_CheckedChanged(object sender, EventArgs e)
		{
			_currentFilterPreferences.SetShowDefaultValuesPage = chkDefaultValues.Checked;
		}
		private void chkParameters_CheckedChanged(object sender, EventArgs e)
		{
			_currentFilterPreferences.SetShowParametersPage = chkParameters.Checked;
		}
		private void chkTriggers_CheckedChanged(object sender, EventArgs e)
		{
			_currentFilterPreferences.SetShowTriggersPage = chkTriggers.Checked;
		}
   }
}
